﻿using System.Windows.Forms;
using AnimationPackerEngine;

namespace AnimatedSpritePacker
{
    public partial class ProgressForm : Form, IPackingProgressDisplay
    {
        public ProgressBar ProgressBar { get { return mProgressBar; } }
        public Label ProgressSection { get { return mProgressSection; } }

        #region IPackingProgressDisplay Members
        private delegate void MarshallDelegate();

        public void ProgressSectionName(string section)
        {
            MarshallDelegate d = delegate()
            {
                ProgressSection.Text = section;
            };

            ProgressSection.Invoke(d);
        }

        public void ResetProgress(int max)
        {
            MarshallDelegate d = delegate()
            {
                ProgressBar.Value = 0;
                ProgressBar.Maximum = max;
            };

            ProgressBar.Invoke(d);
        }

        public void Update(int processed)
        {
            MarshallDelegate d = delegate()
            {
                ProgressBar.Value += processed;
                ProgressBar.Update();
            };

            ProgressBar.Invoke(d);
        }

        public void ProgressComplete()
        {
            MarshallDelegate d = delegate()
            {
                ProgressBar.Value = ProgressBar.Maximum;
                ProgressBar.Update();
            };

            ProgressBar.Invoke(d);
        }
        #endregion

        public ProgressForm()
        {
            InitializeComponent();
        }
    }
}
